﻿namespace System.Web.UI
{
    using System;

    internal class ExpressionArgs
    {
        private System.Web.UI.ViewModel.BindingType _bindingType;
        private string _propertyControlID;
        private string _propertyControlType;
        private string _propertyExpression;

        public ExpressionArgs(string propertyExpression)
        {
            string[] strArray = propertyExpression.Split(new char[] { ',' });
            this._bindingType = System.Web.UI.ViewModel.BindingType.Default;
            foreach (string str in strArray)
            {
                string str3;
                if (!str.Contains("="))
                {
                    this._propertyExpression = str.Trim();
                }
                else
                {
                    string str2 = str.Remove(str.IndexOf("="));
                    str3 = str.Substring(str.IndexOf("=") + 1);
                    string str4 = str2.Trim();
                    if (str4 != null)
                    {
                        if (!(str4 == "ID"))
                        {
                            if (str4 == "Type")
                            {
                                goto Label_00CD;
                            }
                            if (str4 == "Mode")
                            {
                                goto Label_00DB;
                            }
                        }
                        else
                        {
                            this._propertyControlID = str3.Trim();
                        }
                    }
                }
                goto Label_0124;
            Label_00CD:
                this._propertyControlType = str3.Trim();
                goto Label_0124;
            Label_00DB:
                if (str3.Trim() == "OneWay")
                {
                    this._bindingType = System.Web.UI.ViewModel.BindingType.OneWay;
                }
                else if (str3.Trim() == "TwoWay")
                {
                    this._bindingType = System.Web.UI.ViewModel.BindingType.TwoWay;
                }
            Label_0124:;
            }
            if (string.IsNullOrEmpty(this._propertyExpression))
            {
                throw new Exception("Extensions.ViewModel: Expression format error.");
            }
        }

        public virtual System.Web.UI.ViewModel.BindingType BindingType
        {
            get
            {
                return this._bindingType;
            }
        }

        public string Expression
        {
            get
            {
                return this._propertyExpression;
            }
        }

        public bool IsBuildViewModelBase
        {
            get
            {
                return (string.IsNullOrEmpty(this._propertyControlID) && string.IsNullOrEmpty(this._propertyControlType));
            }
        }

        public string PropertyControlID
        {
            get
            {
                return this._propertyControlID;
            }
        }

        public string PropertyControlType
        {
            get
            {
                return this._propertyControlType;
            }
        }
    }
}

